<!DOCTYPE html>
<html lang="en">

<head>
    <#include "/pages/admin_include/head.html"/>
    <script type="text/javascript" charset="utf-8" src="pages/admin/assets/ueditor1_4_3_3/ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="pages/admin/assets/ueditor1_4_3_3/ueditor.all.min.js"> </script>
    <!--建议手动加在语言，避免在ie下有时因为加载语言失败导致编辑器加载失败-->
    <!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型，比如你在配置项目里配置的是英文，这里加载的中文，那最后就是中文-->
    <script type="text/javascript" charset="utf-8" src="pages/admin/assets/ueditor1_4_3_3/lang/zh-cn/zh-cn.js"></script>

    <style type="text/css">
        div{
            width:100%;
        }
    </style>
</head>

<body data-type="widgets">
<script src="pages/admin/assets/js/theme.js"></script>
<div class="am-g tpl-g">
    <!-- 头部 -->
    <header>
        <!-- logo -->
        <div class="am-fl tpl-header-logo">
            <a href="javascript:;"><img src="pages/admin/assets/img/logo.png" alt=""></a>
        </div>
    </header>
    <!-- 侧边导航栏 -->
    <#include "/pages/admin_include/menu.html"/>

    <!-- 内容区域 -->
    <div class="tpl-content-wrapper">
        <div class="row-content am-cf">
            <div class="row">
                <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
                    <div class="widget am-cf">
                        <div class="widget-head am-cf">
                            <div class="widget-title am-fl">新增文章</div>
                        </div>
                        <div class="widget-body am-fr">
                            <form id="textForm" class="am-form tpl-form-border-form tpl-form-border-br" method="post" action="admin/article/saveText">
                                <input type="hidden" name="id" id="id" value="${id!}">
                                <input type="hidden" name="text" value="${text!}">
                                <div class="am-form-group">
                                    <script id="editor" type="text/plain" style="width:1024px;height:500px;">
                                        ${(article.content)!}
                                    </script>
                                </div>
                                <div class="am-form-group">
                                    <div class="am-u-sm-9 am-u-sm-push-3">
                                        <button type="button" class="am-btn am-btn-primary tpl-btn-bg-color-success" onclick="javascript:submitText();">
                                            提交
                                        </button>
                                        <a type="button" class="am-btn am-btn-primary tpl-btn-bg-color-success " href="admin/article?pageNumber=${pageNumber!}&pageSize=${pageSize!}">
                                            返回
                                        </a>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- footer_js -->
<#include "/pages/admin_include/footer_js.html"/>
<script type="text/javascript">
    //实例化编辑器
    //建议使用工厂方法getEditor创建和引用编辑器实例，如果在某个闭包下引用该编辑器，直接调用UE.getEditor('editor')就能拿到相关的实例
    var ue = UE.getEditor('editor',{
        toolbars: [
            [ 'source', 'undo', 'redo'],
            ['bold', 'italic', 'underline', 'fontborder',
                'strikethrough', 'superscript', 'subscript',
                'removeformat', 'formatmatch', 'autotypeset',
                'blockquote', 'pasteplain', '|', 'forecolor',
                'backcolor', 'insertorderedlist', 'insertunorderedlist',
                'selectall', 'cleardoc']
        ]
    });

    function getContent() {
        var arr = [];
        arr.push("使用editor.getContent()方法可以获得编辑器的内容");
        arr.push("内容为：");
        arr.push(ue.getContent());
        alert(arr.join("\n"));
    }

    function submitText() {
        //textForm
        //alert(ue.hasContents());
        if(!ue.hasContents()) {
            alert("请填写文章内容。");
        } else {
            $("input[name='text']").val(ue.getContent());
            $("#textForm").submit();
        }
    }

</script>
</body>

</html>